import React from 'react';
import ReactDOM from 'react-dom';
import { backstageUrl, baseUrl } from "./config.js";
import Axios from "axios";


Axios.defaults.baseURL = baseUrl;

export let addGridOneApi = (formData) => {
    return (
        Axios({
            method: 'post',
            url: backstageUrl + 'basicDataImport/addGridOne',
            headers: { "Content-Type": "multipart/form-data" },
            processData: false,
            data: formData
        })
    );
}


export let addGridTwoApi = (formData) => {
    return (
        Axios({
            method: 'post',
            url: backstageUrl + 'basicDataImport/addGridTwo',
            headers: { "Content-Type": "multipart/form-data" },
            processData: false,
            data: formData
        })
    );
}


export let addGridThreeApi = (formData) => {
    return (
        Axios({
            method: 'post',
            url: backstageUrl + 'basicDataImport/addGridThree',
            headers: { "Content-Type": "multipart/form-data" },
            processData: false,
            data: formData
        })
    );
}

export let addGridStudentApi = (formData) => {
    return (
        Axios({
            method: 'post',
            url: backstageUrl + 'basicDataImport/addGridStudent',
            headers: { "Content-Type": "multipart/form-data" },
            processData: false,
            data: formData
        })
    );
}


export let addGridMemberApi = (formData) => {
    return (
        Axios({
            method: 'post',
            url: backstageUrl + 'basicDataImport/addGridInfo',
            headers: { "Content-Type": "multipart/form-data" },
            processData: false,
            data: formData
        })
    );
}

export let addGridFiveOldStaffApi = (formData) => {
    return (
        Axios({
            method: 'post',
            url: backstageUrl + 'basicDataImport/addGridFiveOldStaff',
            headers: { "Content-Type": "multipart/form-data" },
            processData: false,
            data: formData
        })
    );
}

export let addGridOutAdminApi = (formData) => {
    return (
        Axios({
            method: 'post',
            url: backstageUrl + 'basicDataImport/addGridOutAdmin',
            headers: { "Content-Type": "multipart/form-data" },
            processData: false,
            data: formData
        })
    );
}


//得到学校所有校内网格成员信息
export let inAdminGridApi = (schoolId) => {
    return (
        Axios.get(backstageUrl + "inAdminGrid/getInGridMember", {
            params: {
                schoolId: schoolId
            }
        })
    )
}

//得到所有网格长等级
export let getAllInGridMemberTypeApi = (schoolId) => {
    return (
        Axios.get(backstageUrl + "inAdminGrid/getAllInGridMemberType", {
            params: {
                schoolId: schoolId
            }
        })
    )
}



// export let getAllInAdminGridMemberByGridparentApi = (schoolId, gridParent) => {
//     return (
//         Axios.get(backstageUrl + "inAdminGrid/getAllInAdminGridMemberByGridparent", {
//             params: {
//                 schoolId: schoolId,
//                 gridParent: gridParent
//             }
//         })
//     )
// }

export let getAllGridByGridparentIdApi = (schoolId, gridparentId) => {
    return (
        Axios.post(backstageUrl + "inAdminGrid/getAllGridByGridparentId", {
            schoolId: schoolId,
            gridparentId: gridparentId
        })
    )
}

export let getEchartsGridByGridparentIdApi = (schoolId, gridparentId) => {
    return (
        Axios.post(backstageUrl + "inAdminGrid/getEchartsGridByGridparentId", {
            schoolId: schoolId,
            gridparentId: gridparentId
        })
    )
}
export let getMatrixEchartsGridByGridparentIdApi = (schoolId, gridparentId)=>{
    return(
        Axios.post(backstageUrl+"inAdminGrid/getMatrixEchartsGridByGridparentId", {
            schoolId: schoolId,
            gridparentId: gridparentId
        })
    )
}
export let getMatrixEchartsinspectAndpatrolandSecurityApi =(schoolId)=>{
    return(
        Axios.get(backstageUrl+"schoolSafetySupervisor/getInspectAndPatrolAndSecurityTree", {
            params:{
                schoolId:schoolId
            }
        })
    )
}

//修改校内网格成员
// export let updateInAdminGridApi = (stulist) => {
//     return (
//         Axios.post(backstageUrl + "inAdminGrid/updateInAdminGrid", {
//             gridName: stulist.gridName,
//             gridAdmin: stulist.gridAdmin,
//             id: stulist.id,
//             adminPhone: stulist.adminPhone,
//             schoolId: stulist.schoolId,

//         })
//     )
// }
export let updateGridInfoApi = (gridlist, gridchargeId, gridnameId) => {
    return (
        Axios.post(backstageUrl + "inAdminGrid/updateGridInfo", {
            gridname: gridlist.gridname,
            gridcharge: gridlist.gridcharge,
            gridchargeId: gridchargeId,
            gridnameId: gridnameId,
            phone: gridlist.phone,
            schoolId: gridlist.schoolId,

        })
    )
}


//删除校内网格成员
// export let deleteInAdminGridApi = (id, schoolId) => {
//     return (
//         Axios.post(backstageUrl + "inAdminGrid/deleteInAdminGrid", {
//            id: id,
//            schoolId: schoolId      
//         })
//     )
// }
export let deleteGridInfoApi = (id, schoolId) => {
    return (
        Axios.post(backstageUrl + "inAdminGrid/deleteGridInfo", {
            id: id,
            schoolId: schoolId
        })
    )
}
export let deleteTotalGridInfoApi = (id, schoolId) => {
    return (
        Axios.post(backstageUrl + "inAdminGrid/deleteTotalGridInfo", {
            id: id,
            schoolId: schoolId
        })
    )
}
export let deleteAllGridInfoApi = (schoolId) => {
    return (
        Axios.post(backstageUrl + "inAdminGrid/deleteAllGridInfo", {
            
            schoolId: schoolId
        })
    )
}

export let isHasGridInfoApi = (schoolId) => {
    return (
        Axios.get(backstageUrl + "inAdminGrid/isHasGridInfo", {
            params: {
                schoolId: schoolId
            }
        })
    )
}

export let getFirstGridAddressInfoApi = (schoolId, gridlevel) => {
    return (
        Axios.post(backstageUrl + "inAdminGrid/getFirstGridAddressInfo", {
            schoolId: schoolId,
            gridlevel: gridlevel
        })
    )
}

export let getFirstGridChargeInfoApi = (schoolId, gridlevel) => {
    return (
        Axios.post(backstageUrl + "inAdminGrid/getFirstGridChargeInfo", {
            schoolId: schoolId,
            gridlevel: gridlevel
        })
    )
}

export let addFirstGridInfoApi = (schoolId, gridnameId, gridchargeId, gridparentId) => {
    return (
        Axios.post(backstageUrl + "inAdminGrid/addFirstGridInfo", {
            schoolId: schoolId,
            gridnameId: gridnameId,
            gridchargeId: gridchargeId,
            gridparentId: gridparentId
        })
    )
}
export let addGridAddressAndChargeInfo = (schoolId, gridname, gridlevel, gridcharge, phone) => {
    return (
        Axios.post(backstageUrl + "inAdminGrid/addGridAddressAndChargeInfo",  {
            schoolId: schoolId,
            gridname:gridname,
            gridlevel:gridlevel,
            gridcharge:gridcharge,
            phone:phone
        })
    )
}
export let addGridChargeInfoApi = (schoolId, gridcharge, phone, gridlevel) => {
    return (
        Axios.post(backstageUrl + "inAdminGrid/addGridChargeInfo", {
            schoolId: schoolId,
            gridcharge:gridcharge,
            phone:phone,
            gridlevel:gridlevel
        })
    )
}
export let getAllGridChargeLevelApi = (schoolId)=>{
    return(
        Axios.get(backstageUrl+"inAdminGrid/getAllGridChargeLevel", { 
            params: {
            schoolId:schoolId
            }
        })
    )
}
export let getTotalGridInfoApi=(schoolId)=>{
    return(
        Axios.get(backstageUrl+"inAdminGrid/getTotalGridInfo", { 
            params: {
            schoolId:schoolId
            }
        })
    )
}





